import getApiData, { getNestApiData } from '@/services/cpasRequest';
import { msgError } from '@/utils/msg';
import { replaceInvalidChar } from '@/utils/pub';
import type { IColumnProps } from 'devextreme-react/data-grid';
import { consts } from '../consts';
import { conditionStatesData } from '../tableColumnData';
import type {
  AdvQueryParam,
  DbFieldInfo,
  FormQueryParams,
  ProjectOverallProps,
  RetDataInfo,
  SampleField} from '../typing';
import {
  OverallMode
} from '../typing';
import { exportDataToExcel } from './exportExcelService';
/**
 * 获取字段文本
 * @param fieldsInfoArray
 * @param fields
 */
export function getFieldsTexts(fieldsInfoArray: SampleField[], fields: string[]) {
  return fieldsInfoArray
    .filter((item) => fields.includes(item.fieldName))
    .map((item) => item.fieldTitle)
    .join('、');
}

export function getIniFormQueryParams(): FormQueryParams {
  return {
    // yearID: sjnd,
    dataId: '',
    kmbhOperator: consts.startIsText,
    kmbhStr: '',
    kmmcStr: '',
    dfkmOperator: '包含',
    dfkmStr: '',
    hsxmStr: '',
    jeFx: consts.JF_DF_Text, //'借或贷',//['', '借方', '贷方', '借或贷']
    jeOperator: '>',
    jeStartValue: 0,
    jeEndValue: 0,
    pzlxStr: '',
    zyStr: '',
    monthStartStr: '',
    monthEndStr: '',
    includeJzpz: false,
    //  xswzpzCheck: false,
    // checkQueryContent: true
  };
}

export function generateYearMonths(year: number | string): string[] {
  const result: string[] = [
    /* {
        id: 0,
        selectName: ''
    } */
  ];
  for (let month = 1; month < 13; month++) {
    result.push(year.toString() + month.toString().padStart(2, '0'));
    /*  result.push({
             id: month,
             selectName: year.toString() + (month).toString().padStart(2, '0')
         }); */
  }
  return result;
}
/**
 * 获取评凭证类型列表
 * @param params
 * @returns [{PZLX}]
 */
export async function getPzlxList(params: {
  dbname: string;
  Data_ID: string;
}): Promise<{ PZLX: string }[]> {
  //凭证类型加缓存,减少查询
  let allPlzxList: any = sessionStorage.getItem('pzlxList');
  const key: string = params.dbname + '-' + params.Data_ID;
  let plzxList;
  if (allPlzxList) {
    try {
      allPlzxList = JSON.parse(allPlzxList);
      plzxList = allPlzxList ? allPlzxList[key] : [];
    } catch (error) {}
  }
  if (Array.isArray(plzxList) && plzxList.length) {
    return plzxList;
  }

  const retData = await getApiData('account.PZB.getPZLX', params);
  if (!retData.ok) {
    // showNotDataMsg(retData.data)
    /* if ((retData.data + '').includes(`${params.dbname}..CW_PZB${params.Data_ID}`)) {
            msgError('还未转换财务数据，不能使用凭证表')
        } else {
            msgError(retData.data)
        } */
  }
  plzxList = retData.ok ? retData.data : [];
  if (plzxList.length) {
    allPlzxList = allPlzxList || {};
    allPlzxList[key] = plzxList;
    sessionStorage.setItem('pzlxList', JSON.stringify(allPlzxList));
  }
  return plzxList;
}
/*
export function getFieldsHtml(sampleAllFieldsArray: SampleField[]) {

    const fields = sampleAllFieldsArray.filter(item => item.visible);
    const fieldsHtml: any[] = [];
    const fieldCnt = fields.length;
    function getOneFieldHtml(sampleField: SampleField) {
        return (
            <div className="itemBoxDispaly" style={{ marginBottom: '8px' }}>
                <div style={{ width: '60px', margin: '0 5px' }}>{sampleField.fieldTitle}</div>
                <TextBox
                    //value={searchParams.kmbhStr}
                    width={150}
                    onValueChange={(value: any) => {
                        console.log(value, '@@@');
                        // changeData('kmbhStr', value);
                    }}
                />
            </div>
        )
    }
    fields.forEach((sampleField1: SampleField, index: number) => {
        if (index % 2 == 0) {
            let oneHtml = (
                <Item location='before' locateInMenu='auto' key={index}>
                    <div>
                        {getOneFieldHtml(sampleField1)}
                        {index + 1 < fieldCnt ? getOneFieldHtml(fields[index + 1]) : null}
                    </div>
                </Item>
            )
            fieldsHtml.push(oneHtml);
        }

    });
    return fieldsHtml;
} */

export const sqlTextFun = (itemVal: any) => {
  let andorStrSql: string = '';
  let leftParenthesisSql: string = '';
  let StateIDSql: string = '';
  let rightParenthesisSql: string = '';
  const {
    andorStr,
    leftParenthesis,
    conditionsName,
    StateID,
    rowConditionsData,
    rightParenthesis,
  } = itemVal;

  if (andorStr === '0') {
    andorStrSql = '或';
  } else {
    andorStrSql = '且';
  }
  if (leftParenthesis === '1') {
    leftParenthesisSql = '（';
  } else {
    leftParenthesisSql = '';
  }
  StateIDSql = conditionStatesData[StateID].conditionName;
  if (rightParenthesis === '1') {
    rightParenthesisSql = '）';
  } else {
    rightParenthesisSql = '';
  }
  let str = `${andorStrSql} ${leftParenthesisSql}`; // `${andorStrSql}（${leftParenthesisSql && rightParenthesisSql ? leftParenthesisSql : ''} `
  str += `【${conditionsName}】${StateIDSql}【${rowConditionsData || consts.emptyText}】`;
  str += `${rightParenthesisSql}`;

  //str += `${leftParenthesisSql && rightParenthesisSql ? rightParenthesisSql : ''}）`;

  return str;
};

export const sqlStrFun = (itemVal: any, index: number) => {
  let andorStrSql: string = '';
  let leftParenthesisSql: string = '';
  let StateIDSql: string = '';
  let rightParenthesisSql: string = '';
  let rowDataStrSql: string = '';

  const {
    andorStr,
    leftParenthesis,
    StateID,
    rowConditionsData,
    rightParenthesis,
    keyString,
    sqlType,
  } = itemVal;

  const isNullSql: string | number = sqlType === 'string' ? `''` : 0;
  if (andorStr === '0') {
    andorStrSql = 'or';
  } else {
    andorStrSql = 'and';
  }
  if (leftParenthesis === '1') {
    leftParenthesisSql = '(';
  } else {
    leftParenthesisSql = '';
  }
  StateIDSql = conditionStatesData[StateID].slqfh;
  //是否包含结转凭证字段
  if (keyString == 'IdentifyJZ') {
    rowDataStrSql = rowConditionsData == consts.no ? getNotIncludeJzpz() : '1=1';
  } else if (StateID === 7 || StateID === 8) {
    rowDataStrSql = `'%${rowConditionsData}%'`;
  } else if (StateID === 9) {
    rowDataStrSql = `'${rowConditionsData}%'`;
  } else if (StateID === 10) {
    rowDataStrSql = `'%${rowConditionsData}'`;
  } else if (StateID === 11 || StateID === 12) {
    rowDataStrSql = `''`;
  } else if (StateID === 13) {
    rowDataStrSql = `Len(IsNull(${keyString}, ${isNullSql})) = ${rowConditionsData}`;
  } else {
    rowDataStrSql = `'${rowConditionsData}'`;
  }

  if (rightParenthesis === '1') {
    rightParenthesisSql = ')';
  } else {
    rightParenthesisSql = '';
  }

  /*    if (keyString === 'FSE') {
           let FSEDataStrSql = 'IsNull((IsNull(JFJE,0) + IsNull(DFJE,0)),0)';
           if (StateID === 13) {
               FSEDataStrSql = `Len(IsNull((IsNull(JFJE,0) + IsNull(DFJE,0)),0)) = ${rowConditionsData}`;
               return `${andorStrSql} (${leftParenthesisSql && rightParenthesisSql ? leftParenthesisSql : ''} ${FSEDataStrSql} ${leftParenthesisSql && rightParenthesisSql ? rightParenthesisSql : ''})`;
           }
           return `${andorStrSql} (${leftParenthesisSql && rightParenthesisSql ? leftParenthesisSql : ''} ${FSEDataStrSql} ${StateIDSql} ${rowDataStrSql} ${leftParenthesisSql && rightParenthesisSql ? rightParenthesisSql : ''})`;
       }
       if (StateID === 13) {
           return `${andorStrSql} (${leftParenthesisSql && rightParenthesisSql ? leftParenthesisSql : ''} ${rowDataStrSql} ${leftParenthesisSql && rightParenthesisSql ? rightParenthesisSql : ''})`;
       }
       const str = `${andorStrSql} (${leftParenthesisSql && rightParenthesisSql ? leftParenthesisSql : ''} IsNull(${keyString}, ${isNullSql}) ${StateIDSql} ${rowDataStrSql} ${leftParenthesisSql && rightParenthesisSql ? rightParenthesisSql : ''})`;
       */
  let retStr = '';
  if (keyString === 'FSE') {
    let FSEDataStrSql = 'IsNull((IsNull(JFJE,0) + IsNull(DFJE,0)),0)';
    if (StateID === 13) {
      FSEDataStrSql = `Len(IsNull((IsNull(JFJE,0) + IsNull(DFJE,0)),0)) = ${rowConditionsData}`;
      // return `${andorStrSql} (${leftParenthesisSql && rightParenthesisSql ? leftParenthesisSql : ''} ${FSEDataStrSql} ${leftParenthesisSql && rightParenthesisSql ? rightParenthesisSql : ''})`;
    }
    retStr = FSEDataStrSql;
    // return `${andorStrSql} (${leftParenthesisSql && rightParenthesisSql ? leftParenthesisSql : ''} ${FSEDataStrSql} ${StateIDSql} ${rowDataStrSql} ${leftParenthesisSql && rightParenthesisSql ? rightParenthesisSql : ''})`;
  } else if (StateID === 13 || keyString == 'IdentifyJZ') {
    retStr = rowDataStrSql;
    //return `${andorStrSql} (${leftParenthesisSql && rightParenthesisSql ? leftParenthesisSql : ''} ${rowDataStrSql} ${leftParenthesisSql && rightParenthesisSql ? rightParenthesisSql : ''})`;
  } else {
    retStr = `IsNull(${keyString}, ${isNullSql}) ${StateIDSql} ${rowDataStrSql}`;
    //const str = `${andorStrSql} (${leftParenthesisSql && rightParenthesisSql ? leftParenthesisSql : ''} IsNull(${keyString}, ${isNullSql}) ${StateIDSql} ${rowDataStrSql} ${leftParenthesisSql && rightParenthesisSql ? rightParenthesisSql : ''})`;
  }

  retStr = `${andorStrSql} ${leftParenthesisSql} ${retStr} ${rightParenthesisSql}`;

  return retStr;
};
/**
 * 通过操作符号获取一个字段的sql
 * @param fielName
 * @param operator
 * @param value
 * @returns
 */
export function getOneFieldSqlByOperator(fielName: string, operator: string, value: any) {
  let sql = '';

  //empty, equalText, includeText, decludeText, startIsText, endIsText

  switch (operator) {
    case consts.equalText:
      sql = `${fielName}  = '${value}' `;
      break;
    case consts.includeText:
      sql = `${fielName}  like '%${value}%' `;
      break;
    case consts.decludeText:
      sql = `${fielName} not like '%${value}%' `;
      break;
    case consts.startIsText:
    case consts.leftInclude:
      sql = `${fielName}  like '${value}%' `;
      break;
    case consts.endIsText:
    case consts.rightInclude:
      sql = `${fielName}  like '%${value}' `;
      break;
  }

  return sql;
}
/**
 * ts把字符串的多个空格替换为一个

 * @param str
 * @returns
 */
function replaceMultipleSpaces(str: string): string {
  return str.replace(/\s+/g, ' ').trim();
}
/**
 * 不包含结转的的条件
 * @returns
 */
function getNotIncludeJzpz() {
  return ' (IdentifyJZ is null or IdentifyJZ=0 ) ';
}
/**
 * 获取凭证界面查询的sql条件
 * @param allParams
 * @param queryDataParams
 */
export const getFormQueryWhereSql = (yearMonths: string[], formQueryParams: FormQueryParams) => {
  let {
    dataId,
    kmbhOperator,
    kmbhStr,
    kmmcStr,
    dfkmOperator,
    dfkmStr,
    hsxmStr,
    jeFx,
    jeOperator,
    jeStartValue,
    jeEndValue,
    pzlxStr,
    zyStr,
    monthStartStr,
    monthEndStr,
    includeJzpz,
  } = formQueryParams;

  let allSqlText = '';
  //不要dataId,凭证就限制了年度
  let kmbhSqlText = '';
  let kmmcSqlText = '';
  let hsxmSqlText = '';
  let dfkmSqlText = '';
  let pzlxSqlText = '';
  let zySqlText = '';
  let jeSqlText = '';
  let monthStartSqlText = '';
  const monthEndSqlText = '';
  let stringArray: string[];
  let includeJzpzSqlText = '';

  if (kmbhStr && kmbhOperator) {
    stringArray = kmbhStr.split(',');
    kmbhSqlText =
      ' and (' +
      stringArray
        .map((value) => getOneFieldSqlByOperator('YSKMBH', kmbhOperator, value))
        .join(' or ') +
      ')';
  }

  if (kmmcStr) {
    //科目名称
    stringArray = kmmcStr.split(',');
    kmmcSqlText =
      ' and (' +
      stringArray
        .map((value) => getOneFieldSqlByOperator('KMMC', consts.includeText, value))
        .join(' or ') +
      ')';
  }
  if (hsxmStr) {
    //核算项目
    stringArray = hsxmStr.split(';');
    hsxmSqlText =
      ' and (' +
      stringArray
        .map((value) => getOneFieldSqlByOperator('HSXM', consts.includeText, value))
        .join(' or ') +
      ')';
  }
  if (dfkmStr && dfkmOperator) {
    //对方科目
    stringArray = dfkmStr.split(',');
    // and ( DFKMMC like '%库存现金%' Or  DFKMMC like '%银行存款%' Or  DFKMMC like '%银行存款-建行纳税户%')
    dfkmSqlText =
      ' and ( ' +
      stringArray
        .map((value) => getOneFieldSqlByOperator('DFKMMC', dfkmOperator, value))
        .join(' or ') +
      ')';
  }

  if (pzlxStr) {
    //凭证类型
    pzlxSqlText = `and PZLX='${pzlxStr}'`;
  }
  if (zyStr) {
    // 摘要
    stringArray = zyStr.split(',');
    //  zySqlText = `and (ZY Like '%${zyStr}%')`;
    zySqlText =
      ' and (' +
      stringArray
        .map((value) => getOneFieldSqlByOperator('ZY', consts.includeText, value))
        .join(' or ') +
      ')';
  }
  if (jeFx && jeOperator && jeStartValue != undefined) {
    //金额
    if (jeOperator == consts.betweenText) {
      //介于
      //如果开始值大于结束值,则交换
      if (jeStartValue > jeEndValue) {
        [jeStartValue, jeEndValue] = [jeEndValue, jeStartValue];
      }
      if (jeEndValue != undefined) {
        if (jeFx === '贷方') {
          jeSqlText = `and ( abs(DFJE) between ${jeStartValue} and ${jeEndValue} )`;
        } else if (jeFx === '借方') {
          jeSqlText = `and ( abs(JFJE)  between ${jeStartValue} and ${jeEndValue}  )`;
        } else {
          //借或贷
          jeSqlText = `and ( ( abs(DFJE)<>0 and  abs(DFJE) between ${jeStartValue} and ${jeEndValue} )
                    or ( abs(JFJE)<>0 and  abs(JFJE) between ${jeStartValue} and ${jeEndValue} ) )`;
        }
      }
    } else {
      //期间操作符号<单个的>
      if (jeFx === '贷方') {
        jeSqlText = `and ( abs(DFJE) ${jeOperator} ${jeStartValue} )`;
      } else if (jeFx === '借方') {
        jeSqlText = `and ( abs(JFJE)  ${jeOperator} ${jeStartValue} )`;
      } else {
        //借或贷
        jeSqlText = `and ( ( abs(DFJE)<>0 and  abs(DFJE) ${jeOperator} ${jeStartValue})
                 or ( abs(JFJE) <>0 and  abs(JFJE) ${jeOperator} ${jeStartValue}  ) )`;
      }
    }
  }

  // 结转凭证-- 包含时,不加条件
  if (!includeJzpz) {
    //不包含时
    includeJzpzSqlText = ' and  ' + getNotIncludeJzpz();
  }
  //日期是首月和末月,不加条件

  if (monthStartStr && monthStartStr != yearMonths[0]) {
    monthStartSqlText = `and left(PZRQ,6)>='${monthStartStr}'`;
  }

  if (monthEndStr && monthEndStr != yearMonths[yearMonths.length - 1]) {
    monthStartSqlText += `and left(PZRQ,6)<='${monthEndStr}'`;
  }

  allSqlText = `${kmbhSqlText} ${kmmcSqlText} ${hsxmSqlText} ${dfkmSqlText} ${pzlxSqlText}   `;
  allSqlText += `${zySqlText} ${jeSqlText} ${monthStartSqlText} ${monthEndSqlText} ${includeJzpzSqlText}`;

  return replaceMultipleSpaces(allSqlText);
};
/**
 * 获取抽样总体的sql条件
 * @param whereSqlParams
 */
export function getSampleOverallWhereSQL(whereSqlParams: {
  isAdvQuery?: boolean;
  advQueryParams?: AdvQueryParam[];
  yearMonths?: string[];
  formQueryParams?: FormQueryParams;
}) {
  //查询条件
  let whereSql = '';
  if (whereSqlParams.isAdvQuery) {
    //高级查询
    if (whereSqlParams.advQueryParams) {
      whereSql = whereSqlParams.advQueryParams
        .map((item, index) => sqlStrFun(item, index))
        .join(' ');
      if (whereSqlParams.advQueryParams.length) {
        const item: any = whereSqlParams.advQueryParams[0];
        if (item.andorStr == '0') {
          //如果高级查询第一个是or 要则加上and (1=0)
          whereSql = ` and (1=0  ${whereSql} ) `;
        } else {
          //如果 高级查询第一个是and 要则加上or (1=1)
          whereSql = ` and (1=1  ${whereSql} ) `;
        }
      }
    }
  } else {
    //界面查询
    whereSql = getFormQueryWhereSql(
      whereSqlParams.yearMonths as any,
      whereSqlParams.formQueryParams as any,
    );
  }
  return ' /*getSampleOverallWhereSQL:*/ ' + whereSql;
}
/**
 * 获取输出数据源
 * @param dataParams
 * @returns
 */
export async function getExportGridDataSource(
  dataParams: any,
  onBeforeExportData?: (retDataInfo: { rowsData: any[]; totalCount: number }) => void,
): Promise<any[]> {
  const retData = await getApiData('sample.getSampleSourceDataList', {
    ...dataParams,
    pageIndex: 0,
    pageSize: consts.maxExportCount,
  });

  if (!retData.ok) {
    msgError(retData.data);
    return [];
  }

  const rowsData: any[] = retData.data;
  //导出前处理数据
  if (onBeforeExportData) {
    onBeforeExportData({ rowsData, totalCount: rowsData.length ? rowsData[0].tc : 0 });
  }
  return rowsData;
}
/**
 * 导出数据到文件
 * @param dataParams
 */
export async function selectFileAndExportDataToExcel(
  columns: IColumnProps[],
  dataParams: any,
  defaultFileNameOnly: string,
  onBeforeExportData?: (retDataInfo: RetDataInfo) => void,
) {
  const fileFullName = replaceInvalidChar(defaultFileNameOnly).replaceAll('：', '');
  const $desktop: any = (window as any).$desktop;
  if($desktop) {
    $desktop.invoke({
      channel: "toggleOverlay",
      data: {
        visible: true, // 是否显示
        timeout: 600000, // 超时时间，默认5000ms
      },
    });
  }
  /*  const retData = await getApiData('sample.getSampleSourceDataList',
         {
             ...dataParams,
             pageIndex: 0,
             pageSize: consts.maxExportCount
         }
     );

     if (!retData.ok) return msgError(retData.data)

     const rowsData: any[] = retData.data;

     //导出前处理数据
     onBeforeExportData && onBeforeExportData({ rowsData, totalCount: (rowsData.length ? rowsData[0].tc : 0) }); */
  const rowsData = await getExportGridDataSource(dataParams, onBeforeExportData);
  //执行输出
  exportDataToExcel(columns, rowsData, fileFullName);
  $desktop.invoke({
    channel: "toggleOverlay",
    data: {
      visible: false, // 是否显示
    },
  });
}
/**
 * 获取样本总体的 模式
 * @param props
 */
export function getOverallMode(props: ProjectOverallProps) {
  const isOverallAddMode = props.overallMode == OverallMode.overallAdd;
  const isOverallEditMode = props.overallMode == OverallMode.overallEdit;
  const isViewMode = props.overallMode == OverallMode.view;
  const isSelectMode = props.overallMode == OverallMode.select;
  const isSampleList = props.overallMode == OverallMode.sampledList;
  const isSampleListManualAddMode = props.overallMode == OverallMode.sampleListManualAdd;
  return {
    isOverallAddMode,
    isOverallEditMode,
    isViewMode,
    isSelectMode,
    isSampleList,
    isSampleListManualAddMode,
  };
}
/**
 * 更新数据行号
 * @param rowsData
 * @param pageIndex
 * @param pageSize
 * @param sampleSourceFields
 */
export function udpateRowsDataRnValue(
  rowsData: any[],
  pageIndex: number,
  pageSize: number,
  sampleSourceFields?: SampleField[],
) {
  //处理数据
  rowsData.forEach((item: any, index: number) => {
    item.rn = pageIndex * pageSize + (index + 1);
    sampleSourceFields?.forEach((field: SampleField) => {
      if (field.isNum && (item[field.fieldName] == '0' || item[field.fieldName] == '0.00')) {
        item[field.fieldName] = ''; //零值显示为空
      }
    });
  });
}
/**
 * 抽样类型列
 * @returns
 */
export function getSampleTypeColumns(): IColumnProps[] {
  return [
    {
      dataField: 'sampleType',
      caption: '样本类型',
      width: 110,
      allowEditing: false,
      alignment: 'center',
      allowSorting: false,
      allowFiltering: false,
    },
    {
      dataField: 'sampleFrequency',
      caption: '抽样次数',
      width: 110,
      allowEditing: false,
      alignment: 'center',
      allowSorting: false,
      allowFiltering: false,
    },
  ];
}
/**
 * 初始化界面查询参数和高级查询参数
 * @param projectOverallProps
 */
export function iniFormQueryAndAdvParams(projectOverallProps?: ProjectOverallProps) {
  if (projectOverallProps?.curWhereSqlParams) {
    const includeJzpz = projectOverallProps.curWhereSqlParams.formQueryParams?.includeJzpz;
    projectOverallProps.curWhereSqlParams.advQueryParams = [];
    projectOverallProps.curWhereSqlParams.formQueryParams = getIniFormQueryParams();
    projectOverallProps.curWhereSqlParams.isAdvQuery =
      !!projectOverallProps.curSampleTable?.isCustom;
    //保留结转凭证属性,否则会导致bug: CPAS6ZT-3632?filter=12301
    projectOverallProps.curWhereSqlParams.formQueryParams.includeJzpz = includeJzpz;
  }
}
/**
 * 获取通过界面查询获取项目名称
 * @param formQueryParams
 * @returns
 */
export function getItemNameByFormQueryParams(formQueryParams: FormQueryParams) {
  return formQueryParams.kmmcStr + (formQueryParams.hsxmStr ? `(${formQueryParams.hsxmStr})` : '');
}
export function getKMMCByAdvQueryParams(advQueryParams: AdvQueryParam[]) {
  const kmmcArray = ['KMMC', '科目名称'];
  const kmmcStr = advQueryParams
    ?.filter((item) => kmmcArray.includes(item.keyString || ''))
    .map((item) => item.rowConditionsData)
    .join(',');
  return kmmcStr;
}
/**
 * 获取通过高级查询获取项目名称
 * @param advQueryParams
 * @returns
 */
export function getItemNameByAdvQueryParams(advQueryParams: AdvQueryParam[]) {
  const hsxmArray = ['HSXM', '核算项目'];
  const hsxmStr = advQueryParams
    ?.filter((item) => hsxmArray.includes(item.keyString || ''))
    .map((item) => item.rowConditionsData)
    .join(',');
  return getKMMCByAdvQueryParams(advQueryParams) + (hsxmStr ? `(${hsxmStr})` : '');
}
/**
 * 获取表的字段信息
 * @param dbname
 * @param tableNames
 * @returns
 */
export async function getTableFieldNameInfo(
  dbname: string,
  tableNames: string[],
): Promise<DbFieldInfo[]> {
  const retData = await getNestApiData('/auditSample/getTableFieldNameInfo', 'POST', {
    dbname,
    tableNames,
  });

  if (!retData.ok) {
    msgError(retData.data);
    return [];
  }
  return retData.data;
}

//export function
